#ifndef MPHTTPCLIENTASYNCIMPL_H
#define MPHTTPCLIENTASYNCIMPL_H

/*****************************************
 * HttpClientAsyncImpl 继承于 HttpClientAsync
 *****************************************/

#include "mpHttpClient.h"
#include "mpHttpConnectionManage.h"

namespace MP{
namespace HTTP{
namespace INTERNAL{

class HttpClientAsyncImpl : public HttpClientAsync
{
public:
    HttpClientAsyncImpl(boost::asio::io_context& io_context);
    ~HttpClientAsyncImpl() override;
public:

    virtual void cancel() override;

    virtual void sendAsync(HttpRequestMessage::ptr_s httpRequest,
                           HttpResponseMessage::ptr_s httpResponse,
                           func_send_complete_callback&& complete_callback = nullptr,
                           func_send_progress_callback&& progress_callback = nullptr) override;

    //head
    virtual void headAsync(const std::string& relativeUri,
                           func_send_complete_callback&& complete_callback = nullptr,
                           func_send_progress_callback&& progress_callback = nullptr) override;

    //get
    virtual void getAsync(const std::string& relativeUri,
                          func_send_complete_callback&& complete_callback = nullptr,
                          func_send_progress_callback&& progress_callback = nullptr) override;

    virtual void downloadAsync(const std::string& relativeUri,
                               const std::string& filePath,
                               std::size_t fileOffset = 0,
                               func_send_complete_callback&& complete_callback = nullptr,
                               func_send_progress_callback&& progress_callback = nullptr) override;

    //post
    virtual void postAsync(const std::string& relativeUri,
                           HttpRequestContent::ptr_s content,
                           func_send_complete_callback&& complete_callback = nullptr,
                           func_send_progress_callback&& progress_callback = nullptr) override;
    //put
    virtual void putAsync(const std::string& relativeUri,
                          HttpRequestContent::ptr_s content,
                          func_send_complete_callback&& complete_callback = nullptr,
                          func_send_progress_callback&& progress_callback = nullptr) override;
    //delete
    virtual void delAsync(const std::string& relativeUri,
                          func_send_complete_callback&& complete_callback = nullptr,
                          func_send_progress_callback&& progress_callback = nullptr) override;
private:
    boost::asio::io_context& _io_context;
    HttpConnectionManage::ptr_s _httpConnectionManage;
};

}   //INTERNAL
}   //HTTP
}   //MP


#endif // MPHTTPCLIENTASYNCIMPL_H
